package cn.com.sinosoft.testxmltransform.yewu;

import java.util.ArrayList;
import java.util.List;

import cn.com.sinosoft.testxmltransform.Child;



/**
 * 机构传输类
 * @author lianWuJun
 * @time   2017年2月10日 上午10:17:33
 */
@Child(clazz = { Department.class })
public class Organization {

	private String code;//机构编码
	private String name;//机构名称
	private String level;//机构等级
	private String category;//机构类别
	private String areaCode;//行政区划编码
	private String address;//地址
	private String legalPerson;//法人
	private String contact;//联系电话
	private String introduce;//介绍
	
	private List<Department> departmentList;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public String getCategory() {
		return category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public String getLegalPerson() {
		return legalPerson;
	}

	public void setLegalPerson(String legalPerson) {
		this.legalPerson = legalPerson;
	}

	public List<Department> getDepartmentList() {
		return departmentList;
	}

	public void setDepartmentList(List<Department> departmentList) {
		this.departmentList = departmentList;
	}

	/**
	 * 添加部门
	 * @param department
	 */
	public void addDepartment(Department department){
		if(this.departmentList==null){
			this.departmentList=new ArrayList<Department>();
		}
		this.departmentList.add(department);
	}
	
	/**
	 * 数据转换
	 * 传输类转实体类
	 * @return	机构实体信息
	 */
	public OrganizationEntity toOrganizationEntity() {
		if(this.code == null){
			return null;
		}
		OrganizationEntity organizationEntity = new OrganizationEntity();	
		ObjectUtil.oldToNew(organizationEntity, this, "serialVersionUID");
		return organizationEntity;
	}
	
	/**
	 * 数据转换
	 * 传输类转实体类
	 * @return	List集合
	 */
	public List<DepartmentEntity> toDepartmentEntityList() {
		List<DepartmentEntity> departmentEntities=new ArrayList<DepartmentEntity>();
		if(this.departmentList!=null && this.departmentList.size()>0){
			int size=this.departmentList.size();				
			for(int i=0;i<size;i++){
				Department department=this.getDepartmentList().get(i);
				DepartmentEntity departmentEntity=department.toDepartmentEntity();
				departmentEntities.add(departmentEntity);
			}
		}
		return departmentEntities;
	}
}
